import time
from loguru import logger
from httprunner import __version__
import requests

BASE_URL = "http://mwsys-gw-api.aa5111.com/"

Headers = \
    {
        "Content-Type": "application/json; charset=UTF-8",
        "User-Agent": "Mozilla/5.0 (MoreWin; MallWin/1.1.90) Env/dev (Android;Android OS 8.1.0;zh-CN)",
        "signature": "f7dfdada946c04ac2f7f944933283dbf",
        "x-token": "",
        "x-value": "1000-1000,f0f99242-949f-42be-ae59-550a61773984,1602574020,1.1.90,zh-CN",
    }
params = {"areaCode": "86", "password": "123456", "phone": "13900139213", "type": 101}


def get_httprunner_version():
    return __version__


def sum_two(m, n):
    return m + n


def sleep(n_secs):
    time.sleep(n_secs)


def get_login_token():
    logger.info(f'正在获取用户手机号为{params["phone"]}的token值')
    response = requests.post(BASE_URL + 'members/morewin/login', headers=Headers, json=params)
    result = response.json()
    logger.info(result)
    token = result['data']['token']
    logger.info(f'获取到token值为:{token}')
    return token

